//
//  HMVisitorController.swift
//  TJHWeiBo
//
//  Created by tianjunhui on 16/8/9.
//  Copyright © 2016年 itcast.cn. All rights reserved.
//

import UIKit

class HMVisitorController: UIViewController {
    
    //登录界面
    //判断用户是否登录
    var isLogin: Bool = HMUserAccountViewModel.sharedTools.isLogin
    
    //访问视图View
    var visitorView: HMVisitorView?
    
    override func loadView() {
        if isLogin {
            super.loadView()
        }else{
            
            setUpVisitorView()
        }
    }
    // MARK:  设置访客视图
    func setUpVisitorView(){
        
      
        
        setNav()
         visitorView = HMVisitorView()
        //02实例化闭包
        visitorView?.closure = {
            //3.0
            self.loginAction()
        }
                 view = visitorView
    }
    
    //设置导航
    func setNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem (title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HMVisitorController.loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem (title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HMVisitorController.loginAction))
      
    }
    
    //监听方法
    func loginAction(){
        
        let oauthVC = HMOuthViewController()
       presentViewController(UINavigationController(rootViewController: oauthVC), animated:true, completion: nil)
    
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    

}
